
var math = require("../models/math.js");
var file = require("../models/file.js");

exports.showIndex = function(req,res){
    res.render("index",{

    })
}

exports.showResult = function(req,res){

    var number =req.params.number;

    var t1 = new Date();
    file.read(number,function(resultArr){
        if(resultArr == -1){
            var resultArr = math.calc(number);

            file.save(number,resultArr)

        }

        var t2 = new Date();
        // res.render("result",{
        //     "resultArr":resultArr,
        //     "number":number,
        //     "during":t2 - t1
        // })
        res.send(
            {
                    "resultArr":resultArr,
                    "number":number,
                    "during":t2 - t1
                }
        )
    })

} 